package com.ssy.lingxi.report.controller.mobile;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.report.model.vo.request.MemberMobileMenuUpdateVO;
import com.ssy.lingxi.report.model.vo.request.UpdateMemberMobileCommonlyUsedAppVO;
import com.ssy.lingxi.report.model.vo.response.MemberMobileCommonlyUsedAppVO;
import com.ssy.lingxi.report.model.vo.response.MemberMobileMenuVO;
import com.ssy.lingxi.report.service.IMemberMobileMenuService;
import com.ssy.lingxi.report.service.IMobileCommonlyUsedAppService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu App - 菜单相关接口
 * @author 伍将
 * @date 2021/3/2
 * @version 2.0.0
 */
@RestController
@RequestMapping("/report/mobile/menu/")
public class MobileMenuController extends BaseController {

    @Resource
    private IMobileCommonlyUsedAppService commonlyUsedAppService;

    @Resource
    private IMemberMobileMenuService memberMobileMenuService;

    /**
     * 获取会员常用App
     * @author 伍将
     * @date 2021/3/2
     **/
    @RequestMapping(value = "/getMemberCommonlyUsedApp", method = RequestMethod.GET)
    public Wrapper<MemberMobileCommonlyUsedAppVO> getMemberCommonlyUsedApp(HttpServletRequest httpRequest) {
        return commonlyUsedAppService.getCommonlyUsedApp(getSysUser(httpRequest));
    }

    /**
     * 保存常用App
     * @author 伍将
     * @date 2021/3/2
     **/
    @RequestMapping("/saveCommonlyUsedApp")
    public Wrapper<Void> saveCommonlyUsedApp(HttpServletRequest httpRequest, @RequestBody @Valid List<UpdateMemberMobileCommonlyUsedAppVO> updateListVO) {
        return commonlyUsedAppService.saveCommonlyUsedApp(getSysUser(httpRequest), updateListVO);
    }

    /**
     * 获取会员菜单
     * @author 伍将
     * @date 2021/3/3
     **/
    @RequestMapping(value = "/getMemberMenuList", method = RequestMethod.GET)
    public Wrapper<List<MemberMobileMenuVO>> getMemberMenuList(HttpServletRequest httpRequest) {
        return memberMobileMenuService.getMemberMenuList(getSysUser(httpRequest));
    }

    /**
     * 更新会员菜单
     * @author 伍将
     * @date 2021/3/3
     **/
    @RequestMapping("/updateMemberMenu")
    public Wrapper<Void> updateMemberMenu(HttpServletRequest httpRequest, @RequestBody @Valid List<MemberMobileMenuUpdateVO> updateListVO) {
        return memberMobileMenuService.updateMemberMenu(getSysUser(httpRequest), updateListVO);
    }
}
